<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>订单管理</title>
	<script type="text/javascript" src="<c:url value='/static/js/admin/preSaleOrder/list.js' />"></script>
</head>

<body>
	<c:if test="${!empty param.msg}">
		<div class="alert alert-green fadein-top">
			<span class="close rotate-hover"></span>
			<strong>提示：</strong>
			${param.msg}
		</div>
	</c:if>
	<form id="form" method="post" action="<c:url value='/admin/preSaleOrder/list' />" name="searchForm">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong>订单列表</strong>
			</div>
			<div class="padding border-bottom">
				<div class="line">
					<div class="x6">
						<div class="input-group padding-little-top">
							<input type="text" class="input input-small border-main" name="key" value="${key}" placeholder="请输入：订单号、联系人、联系电话、支付宝账号查询" /> <span class="addbtn">
							<button type="submit" class="button input-small bg-main">筛选</button></span>
						</div>
					</div>
				</div>
			</div>
			<table class="table table-hover">
				<tr>
					<th width="100" style="text-align: center;">订单号</th>
					<th width="155" style="text-align: center;">下单时间</th>
					<th width="100" style="text-align: center;">
						<select name="status" onchange="searchForm.submit()">
							<option value="-1" <c:if test="${status == -1 }">selected="selected"</c:if>>请选择状态</option>
							<option value="0" <c:if test="${status == 0 }">selected="selected"</c:if>>待支付预付款</option>
							<option value="1" <c:if test="${status == 1 }">selected="selected"</c:if>>已支付预付款</option>
							<option value="3" <c:if test="${status == 3 }">selected="selected"</c:if>>已完成</option>
							<option value="97" <c:if test="${status == 97 }">selected="selected"</c:if>>自动取消</option>
							<option value="98" <c:if test="${status == 98 }">selected="selected"</c:if>>退订申请中</option>
							<option value="99" <c:if test="${status == 99 }">selected="selected"</c:if>>已退订</option>
							<option value="100" <c:if test="${status == 100 }">selected="selected"</c:if>>已退款</option>
						</select>
					</th>
					<th width="100" style="text-align: center;">全款金额</th>
					<th width="100" style="text-align: center;">预付款</th>
					<th style="text-align: center;">支付宝账号</th>
					<th width="80" style="text-align: center;">联系人</th>
					<th width="90" style="text-align: center;">联系电话</th>
					<th width="120" style="text-align: center;">操作</th>
				</tr>
				<c:forEach items="${pager.datas}" var="order">
					<tr>
						<td style="text-align: center;">${order.orderCode}</td>
						<td style="text-align: center;"><fmt:formatDate value="${order.orderTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td style="text-align: center;">
							<c:if test="${order.status == 0}">待支付预付款</c:if>
							<c:if test="${order.status == 1}">已支付预付款</c:if>
							<c:if test="${order.status == 3}">已完成</c:if>
							<c:if test="${order.status == 97}">自动取消</c:if>
							<c:if test="${order.status == 98}">退订申请中</c:if>
							<c:if test="${order.status == 99}">已退订</c:if>
							<c:if test="${order.status == 100}">已退款</c:if>
						</td>
						<td style="text-align: center;">￥${order.fullAmount}</td>
						<td style="text-align: center;">￥${order.preAmount}</td>
						<td style="text-align: center;">${order.alipayAccount}</td>
						<td style="text-align: center;">${order.contact.name}</td>
						<td style="text-align: center;">${order.contact.mobile}</td>
						<td style="text-align: center;">
							<a class="button border-green button-little" href="javascript:void(0);" onclick="detail('${order.id}')">详情</a>
							<a class="button border-yellow button-little" href="javascript:void(0);" onclick="del('${order.id}')">废弃</a>
						</td>
					</tr>
				</c:forEach>
			</table>
			<jsp:include page="../../commons/pager.jsp">
				<jsp:param value="list" name="url" />
			</jsp:include>
		</div>
	</form>
	
	<div id="order-body" style="display: none;">
		<div class="dialog-mask" style="z-index:10000"></div>
		<div class="dialog-win" style="position:fixed; width:800px; z-index:10001; left:250px; top:20px;">
			<div class="dialog open">
				<form id="form" class="form">
					<input id="orderId" type="hidden" value="" />
					<div class="dialog-head">
						<span id="order-close" class="close"></span>
						<strong>订单详情</strong>
					</div>
					<div class="dialog-body">
						<div id="reply-content" style="max-height: 300px;min-height:200px; overflow: auto;">
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">订单号</label>
									</div>
									<div class="field x7">
										<span id="orderNum"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">订单状态</label>
									</div>
									<div class="field x7">
										<select id="orderStatus" name="status">
											<option value="0">待支付预付款</option>
											<option value="1">已支付预付款</option>
											<option value="3">已完成</option>
											<option value="97">自动取消</option>
											<option value="98">退订申请中</option>
											<option value="99">已退订</option>
											<option value="100">已退款</option>
										</select>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">下单时间</label>
									</div>
									<div class="field x7">
										<span id="orderTime"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">支付时间</label>
									</div>
									<div class="field x7">
										<span id="payTime"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">全款金额 </label>
									</div>
									<div class="field x7">
										<span id="fullAmount"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">预付款 </label>
									</div>
									<div class="field x7">
										<span id="preAmount"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x4">
										<label for="marketPrice">支付宝账号 </label>
									</div>
									<div class="field x6">
										<span id="alipayAccount"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">联系人 </label>
									</div>
									<div class="field x7">
										<span id="contactName"></span>
									</div>
								</div>
							</div>
							
							<div class="x4">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">联系电话</label>
									</div>
									<div class="field x7">
										<span id="contactMobile"></span>
									</div>
								</div>
							</div>
							<div class="x4" id="alipaySerialSpanDiv" style="display: none;">
								<div class="form-group">
									<div class="label x4">
										<label for="marketPrice">支付宝流水号</label>
									</div>
									<div class="field x6">
										<span id="alipaySerialSpan"></span>
									</div>
								</div>
							</div>
							<div class="x4" id="documentSerialSpanDiv" style="display: none;">
								<div class="form-group">
									<div class="label x3">
										<label for="marketPrice">单据号</label>
									</div>
									<div class="field x7">
										<span id="documentSerialSpan"></span>
									</div>
								</div>
							</div>
							<div class="x12" id="alipaySerialDiv" style="display: none;">
								<div class="form-group">
									<div class="label x2">
										<label for="marketPrice">支付宝流水号</label>
									</div>
									<div class="field x10">
										<input onkeypress="this.value.replace(/\D/gi, \"\")" type="text" data-validate="required:流水号必填,number:请填写正确的支付宝流水号,length#==16:流水号长度为16" placeholder="请填写支付宝流水号" value="" id="alipaySerial" name="alipaySerial" class="input">
									</div>
								</div>
							</div>
							<div class="x12" id="documentSerialDiv" style="display: none;">
								<div class="form-group">
									<div class="label x1">
										<label for="marketPrice">单据号</label>
									</div>
									<div class="field x11">
										<input type="text" data-validate="required:请填写正确的单据号" placeholder="请填写单据号" value="" id="documentSerial" name="documentSerial" class="input">
									</div>
								</div>
							</div>
							<hr />
							<div class="x12">
								<div class="form-group">
									<div class="field x12">
										<table id="detail-product-list" class="table table-hover">
											<tr>
												<th style="text-align: center;">商品</th>
												<th width="70" style="text-align: center;">图片</th>
												<th width="70" style="text-align: center;">数量</th>
												<th width="155" style="text-align: center;">单价</th>
											</tr>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="dialog-foot">
						<button id="order-publish" type="button" class="button bg-green">保存</button>
						<button id="order-del" type="button" class="button bg-green" style="display: none;">废弃</button>
						<button id="order-cancel" type="button" class="button dialog-close">关闭</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>